package util

import "docker-api/internal/model"

// MergeVersionInfo 合并版本信息
func MergeVersionInfo(dbVersion, currentVersion *model.DockerVersion) *model.DockerVersion {
	// 保留数据库中的 ID 和创建时间，更新其他信息
	dbVersion.DockerVersion = currentVersion.DockerVersion
	dbVersion.OsVersion = currentVersion.OsVersion
	dbVersion.ComposeVersion = currentVersion.ComposeVersion

	return dbVersion
}

// ShouldUpdateVersion 判断是否需要更新版本信息
func ShouldUpdateVersion(dbVersion, currentVersion *model.DockerVersion) bool {
	return dbVersion.DockerVersion != currentVersion.DockerVersion ||
		dbVersion.ComposeVersion != currentVersion.ComposeVersion ||
		dbVersion.OsVersion != currentVersion.OsVersion
}
